package com.weblog.upload.client.factory;


import com.weblog.upload.client.UserClient;
import com.weblog.upload.client.impl.UserClientImpl;

import entity.Result;
import entity.StatusCode;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author MaoLin Wang
 * @date 2019/10/2010:37
 */
@Component
public class UserFallBackFactory implements FallbackFactory<UserClient> {
    @Override
    public UserClient create(Throwable throwable) {
        System.out.println("上传微服务调用用户客户端出错:"+throwable.getMessage()==null?"":throwable.getMessage());
        throwable.printStackTrace();
        return new UserClientImpl() {

            @Override
            public Result uploadAvatar(String url) {
                return new Result(false, StatusCode.ERROR,"上传失败");
            }

            @Override
            public Result findAvatarById(String id) {
                return new Result(false, StatusCode.ERROR,"上传执行出错");
            }
        };
    }
}
